﻿using DotNetCore.CAP;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using xk.mqm.test.common;
using xk.mqm.test.common.Entity;

namespace xk.mqm.test.orderservice.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class UserController : ControllerBase, ICapSubscribe
    {
        private MyDBContext _dbcontext;
        public UserController(MyDBContext myDBContext) {
            _dbcontext = myDBContext;
        }
        public List<Users> Get() {
               return   _dbcontext.Users.ToList();
        }
        [CapSubscribe("xk.text.order-service")]
        [NonAction]
        public void RereMsg(Users user) {


           /* Console.WriteLine(headers.Keys.Count);*/
            _dbcontext.Users.Add(user);
            _dbcontext.SaveChanges();

        }
    }
}
